package mspbots.qbd.online.oauth;

import lombok.Data;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * data.connector.teams.core.oauth.TokenState
 *
 * @author Alex bob(https://github.com/vnobo)
 * @date Created by 2020/4/15
 */
@Data
@Validated
public class TokenState implements Serializable {

    @Min(1)
    @NotNull(message = "Params [tenantId] can not be empty.")
    private Long tenantId;

    @NotBlank(message = "Params [accessToken] can not be empty.")
    private String accessToken;

    @NotBlank(message = "Params [realmId] can not be empty.")
    private String realmId;

    public TokenState(Long tenantId, String realmId, String accessToken) {
        this.tenantId = tenantId;
        this.accessToken = accessToken;
        this.realmId = realmId;
    }

    public static TokenState withDefault(Long tenantId) {
        return new TokenState(tenantId, null, null);
    }


    public TokenState setAccessToken(String accessToken) {
        this.accessToken = accessToken;
        return this;
    }

    public TokenState setRealmId(String realmId) {
        this.realmId = realmId;
        return this;
    }
}


